
#include "receiver.h"
#include "usart.h"
#include "drv_uart.h"
#include "dac.h"

/* Callback function declarations ---------------------------------------------*/
uint32_t User_UART1_RxCpltCallback(uint8_t *Recv_Data, uint16_t ReceiveLen);
uint32_t User_UART2_RxCpltCallback(uint8_t *Recv_Data, uint16_t ReceiveLen);

void System_Resource_Init(void)
{
  /* USART Init ------------------------------------*/
  Uart_Init(&huart1, Uart1_Rx_Buff, USART1_RX_BUFFER_SIZE, User_UART1_RxCpltCallback);
  Uart_Init(&huart2, Uart2_Rx_Buff, USART2_RX_BUFFER_SIZE, User_UART2_RxCpltCallback);

}

uint32_t scaleChange(uint8_t data)
{
	float temp=data/256.0*4096.0;
	return (uint32_t)temp;
}


uint32_t User_UART1_RxCpltCallback(uint8_t *Recv_Data, uint16_t ReceiveLen)
{
	
	HAL_DAC_SetValue(&hdac, DAC_CHANNEL_1, DAC_ALIGN_12B_R,scaleChange(Recv_Data[0]) );
	HAL_DAC_SetValue(&hdac, DAC_CHANNEL_2, DAC_ALIGN_12B_R, scaleChange(Recv_Data[1]));
	//HAL_GPIO_TogglePin(LED2_GPIO_Port,LED2_Pin);
	return 0;
}


uint32_t User_UART2_RxCpltCallback(uint8_t *Recv_Data, uint16_t ReceiveLen)
{

	return 0;
}

